﻿@using System.Web.Mvc
@using Webdiyer.WebControls.Mvc
@using KXCXW.Web.CommonClass
@model PagedList<kxcxw.Data.Entities.PublichInformation>
<div id="dvOrders">
    <table>
        <tr>
            <th style="width: 10%">
                @Html.CheckBox("checkAll", new { @onclick = "checkAll()" }) 全选
            </th>
            <th style="width: 7%">
                图片
            </th>
            <th style="width: 25%">
                标题
            </th>
            <th style="width: 10%">@Html.ActionLink("浏览次数", "Index", new { sortOrder = ViewBag.DateSortParm == "VisitsNumber desc" ? "VisitsNumber" : "VisitsNumber desc" })</th>
            <th style="width: 10%">
                发布人
            </th>
            <th style="width: 18%">
                @Html.ActionLink("发布时间", "Index", new { sortOrder = ViewBag.DateSortParm == "Date" ? "Date desc" : "Date" })
            </th>
            <th style="width: 20%">
                操作
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.CheckBox("checkL", new { @value = @item.InformationID })
                </td>
                <td style="padding-left: 5px;">
                    @if (item.InfoType == 1)
                    {
                        <a href="@item.ShopUrl" class="pic" target="_blank" title="@item.Title">
                            <img alt="" src="@Url.Content(ImgHelper.ImgFoldUrl(ImgHelper.img40) + (string.IsNullOrEmpty(item.MapUrl) ? "nullImage.jpg" : item.MapUrl))" /></a>
                    }
                    else
                    {
                        <a href="../Home/ProductDetails?id=@item.InformationID" class="pic" target="_blank" title="@item.Title">
                            <img alt="" src="@Url.Content(ImgHelper.ImgFoldUrl(ImgHelper.img40) + (string.IsNullOrEmpty(item.MapUrl) ? "nullImage.jpg" : item.MapUrl))" /></a>
                    }
                </td>
                <td>
                    @{string title = item.Title;
                      if (title.Length > 20)
                      {
                          title = title.Substring(0, 20) + "...";
                      }
                      if (item.InfoType == 1)
                      {
                        <a href="@item.ShopUrl" class="title" target="_blank" title="@item.Title">
                            @title</a>
                      }
                      else
                      {
                        <a href="../Home/ProductDetails?id=@item.InformationID" class="title" target="_blank" title="@item.Title">@title</a>
                      }
                    }
                </td>
                <td>@item.VisitsNumber</td>
                <td>
                    @Html.DisplayFor(modelItem => item.SysUserInfo.UserName)
                </td>
                <td>
                    @string.Format("{0:D}", DateTime.Parse(@Html.DisplayFor(modelItem => item.PublishDate).ToString()))
                </td>
                <td class="action">
                    @Html.ActionLink("查看", "Details", new { id = item.InformationID }, new { @class = "view", target = "_blank" })
                    |
                    @Html.ActionLink("修改", "Edit", new { id = item.InformationID }, new { @class = "edit", target = "_blank" })
                    |
                    @Html.ActionLink("删除", "Delete", new { id = item.InformationID, order = ViewBag.DateSortParm, searchString = Request.QueryString["searchString"] == null ? "" : Request.QueryString["searchString"].ToString(), page = Request.QueryString["page"] == null ? 1 : Convert.ToInt32(Request.QueryString["page"]) }, new { @class = "delete" })
                </td>
            </tr>
        }
        <tr>
            <td colspan="6">
                共有 @Model.TotalItemCount 条记录 @Model.CurrentPageIndex/@Model.TotalPageCount
                @Html.Pager(
                 Model, new PagerOptions
                 {
                     PageIndexParameterName = "page",
                     FirstPageText = "首页",
                     LastPageText = "尾页",
                     NextPageText = "后一页",
                     PrevPageText = "前一页",
                     ShowPageIndexBox = true,
                     PageIndexBoxType = PageIndexBoxType.TextBox,
                     PageIndexBoxWrapperFormatString = "请输入页数{0}"
                 }, "Admin_default",
                    new { sortOrder = ViewBag.DateSortParm, searchString = ViewBag.Filter }
                    )
            </td>
        </tr>
    </table>
</div>
<script type="text/jscript">
    function checkAll() {
        var ids = document.getElementsByName('checkL');
        for (i = 0; i < ids.length; i++)
            ids[i].checked = true;
    }
    $(function () {
        $(".delete").click(function () {
            if (confirm("确定要删除这条记录么？")) {
                return true;
            }
            else {
                return false;
            }
        });
    }); 
</script>
